package com.henghe.frame.auth.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.concurrent.ConcurrentHashMap;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2023/3/17 10:21
 */
@ConfigurationProperties(
        prefix = "jwt"
)
@Data
public class JWTProperties {
    private String secretKey;
    private String secretPkey;
    private boolean active;
    private String apiToken;
    private String filter;
    /**
     * token 有效期(天）
     */
    private Integer validityDays;

    /**
     * 互踢
     */
    private boolean kick;
    private ConcurrentHashMap<String, String> userRoles;

    public ConcurrentHashMap<String, String> getUserRoles() {
        return this.userRoles;
    }

    public void setUserRoles(ConcurrentHashMap<String, String> userRoles) {
        this.userRoles = userRoles;
    }

    public JWTProperties() {
    }

    public String getSecretKey() {
        return this.secretKey;
    }

    public String getSecretPkey() {
        return this.secretPkey;
    }

    public boolean isActive() {
        return this.active;
    }

    public String getApiToken() {
        return this.apiToken;
    }

    public String getFilter() {
        return this.filter;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public void setSecretPkey(String secretPkey) {
        this.secretPkey = secretPkey;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public void setApiToken(String apiToken) {
        this.apiToken = apiToken;
    }

    public void setFilter(String filter) {
        this.filter = filter;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof JWTProperties)) {
            return false;
        } else {
            JWTProperties other = (JWTProperties) o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$secretPkey = this.getSecretKey();
                Object other$secretPkey = other.getSecretKey();
                if (this$secretPkey == null) {
                    if (other$secretPkey != null) {
                        return false;
                    }
                } else if (!this$secretPkey.equals(other$secretPkey)) {
                    return false;
                }

                this$secretPkey = this.getSecretPkey();
                other$secretPkey = other.getSecretPkey();
                if (this$secretPkey == null) {
                    if (other$secretPkey != null) {
                        return false;
                    }
                } else if (!this$secretPkey.equals(other$secretPkey)) {
                    return false;
                }

                if (this.isActive() != other.isActive()) {
                    return false;
                } else {
                    Object this$filter = this.getApiToken();
                    Object other$filter = other.getApiToken();
                    if (this$filter == null) {
                        if (other$filter != null) {
                            return false;
                        }
                    } else if (!this$filter.equals(other$filter)) {
                        return false;
                    }

                    this$filter = this.getFilter();
                    other$filter = other.getFilter();
                    if (this$filter == null) {
                        if (other$filter != null) {
                            return false;
                        }
                    } else if (!this$filter.equals(other$filter)) {
                        return false;
                    }

                    Object this$userRoles = this.getUserRoles();
                    Object other$userRoles = other.getUserRoles();
                    if (this$userRoles == null) {
                        if (other$userRoles != null) {
                            return false;
                        }
                    } else if (!this$userRoles.equals(other$userRoles)) {
                        return false;
                    }

                    return true;
                }
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof JWTProperties;
    }

    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        Object $secretKey = this.getSecretKey();
        result = result * 59 + ($secretKey == null ? 43 : $secretKey.hashCode());
        Object $secretPkey = this.getSecretPkey();
        result = result * 59 + ($secretPkey == null ? 43 : $secretPkey.hashCode());
        result = result * 59 + (this.isActive() ? 79 : 97);
        Object $apiToken = this.getApiToken();
        result = result * 59 + ($apiToken == null ? 43 : $apiToken.hashCode());
        Object $filter = this.getFilter();
        result = result * 59 + ($filter == null ? 43 : $filter.hashCode());
        Object $userRoles = this.getUserRoles();
        result = result * 59 + ($userRoles == null ? 43 : $userRoles.hashCode());
        return result;
    }

    public String toString() {
        return "JWTProperties(secretKey=" + this.getSecretKey() + ", secretPkey=" + this.getSecretPkey() + ", active=" + this.isActive() + ", apiToken=" + this.getApiToken() + ", filter=" + this.getFilter() + ", userRoles=" + this.getUserRoles() + ")";
    }
}
